package com.lsk.controller;

import com.lsk.internalcommon.DTO.DriverUser;
import com.lsk.internalcommon.DTO.ResponseResult;
import com.lsk.internalcommon.request.VerificationCodeDTO;
import com.lsk.service.VerificationCodeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class VerificationCodeController {
    @Autowired
    private VerificationCodeService verificationCodeService;

    /**
     * 司机获取验证码
     */
    @GetMapping("/verification-code")
    public ResponseResult getVerificationCode(@RequestBody VerificationCodeDTO verificationCode){
        String driverPhone = verificationCode.getDriverPhone();

        log.info("司机手机号是："+driverPhone);
        return verificationCodeService.checkAndSendVerification(driverPhone);
    }

    @PostMapping("/verification-code-check")
    public ResponseResult checkVerificationCode(@RequestBody VerificationCodeDTO verificationCodeDTO){
        String phone = verificationCodeDTO.getDriverPhone();
        String verificationCode = verificationCodeDTO.getVerificationCode();



        return verificationCodeService.check(phone,verificationCode);
    }
}
